﻿/*----------------------------------------------------------------
    // Copyright (C) 2009 江苏华招网
    // 版权所有。 
    // 作者：周传雄 
    //
    // 文件名：DistributePlanList.cs
    // 文件功能描述：退货确认
    // 创建标识：周传雄2009-05-12
    //
    // 修改标识：
    // 修改描述：
    //
    // 修改标识：
    // 修改描述：
    //
    // 审核人：
// 审核时间：
// 审核说明：
 //----------------------------------------------------------------*/

using System;
using System.Collections;
using System.Configuration;
using System.Data;

using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

using System.Collections.Generic;
using HZ.DrugTrade.Web;
using HZ.DrugTrade.Model;
using HZ.DrugTrade.IBLL;
using HZ.DrugTrade.BLLFactory;
using HZ.DrugTrade.Model.Enum;
using System.Data.SqlClient;
using HZ.Common;

namespace HZ.DrugTrade.Web.Enterprise.InvoiceManage
{
    public partial class ReturnConfirm : BasePage
    {
        public ReturnConfirm()
        {
            this.ModuleNo = Module.退货单管理.ToString();
        }

        string str_ReturnSerialID = "";
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!string.IsNullOrEmpty(Request["RSID"]))
            {
                str_ReturnSerialID = Request["RSID"].ToString();
            }           
            if (!Page.IsPostBack)
            {
                QueryResult();
            }
        }

        private void QueryResult()
        {
            IList<Model.View.ReturnMerchandise> ReturnMerchandiseList = new List<Model.View.ReturnMerchandise>();
            Model.Query.ReturnMerchandise qryCondition = new Model.Query.ReturnMerchandise();
            User user = CurrentAccount.GetUser();
            qryCondition.ReturnOrderStatus = 2;//退货单状态：0(空单) 1 (未提交) 2(已提交)
            qryCondition.ReturnName = txtReturnName.Text.ToString().Trim();
            qryCondition.HospitalName = txtHospitalName.Text.ToString().Trim();
            qryCondition.ReturnTimeFrom = new HZ.Common.ConvertHelper(txtBegin.Text.ToString().Trim()).ToDateTime;
            qryCondition.ReturnTimeTo = new HZ.Common.ConvertHelper(txtEnd.Text.ToString().Trim()).ToDateTime;
            if (str_ReturnSerialID != null && str_ReturnSerialID != "")
            {
                qryCondition.Append = " a.ReturnSerialID='" + str_ReturnSerialID.Replace("'", "") + "' ";
            }           
            //AspNetPager1.PageSize = Constants.GRIDVIEW_PAGE_SIZE;
            int totalCount = 0;
            IBLL_Purchase iPurchase = Factory.BLL_Purchase();
            ReturnMerchandiseList = iPurchase.GetReturnMerchandis_Company(qryCondition, user.Org.OrgID, AspNetPager1.CurrentPageIndex, AspNetPager1.PageSize, out totalCount);
            AspNetPager1.RecordCount = totalCount;
            gvwReturnConfirm.DataSource = ReturnMerchandiseList;
            gvwReturnConfirm.DataBind();

        }

        protected void btnQuery_Click(object sender, EventArgs e)
        {
            QueryResult();
        }
        protected void AspNetPager1_OnPageChanged(object sender, EventArgs e)
        {
            QueryResult();
        }
    }
}
